package com.liusu.spider.wuzhou;

import java.util.HashMap;
import java.util.Map;

public class Dict<K,V> extends HashMap<K,V> {


    @Override
    public V get(Object k) {

        if(this.containsKey(k)){
            return super.get(k);
        }
        return (V)"";
    }

    /**
     *
     * @param cookie_string
     */
    public void put_cookie(String cookie_string) {

        String[] cookies = cookie_string.split(";");

        for (String cookie : cookies) {
            if(cookie.endsWith("=")){
                continue;
            }

            String[] kv = cookie.split("=",2);

            this.put((K)kv[0].trim(),(V)kv[1].trim());
        }
    }
    /**
     *
     * @param string
     */
    public void put(String string) {

        String[] kv = string.split(":");
        this.put((K)kv[0].trim(),(V)kv[1].trim());

    }
    public void print(Object content){
        System.out.println(content);
    }
}